<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/js/web/frame/jedate/skin/jedate.css')}}">
    <script src="{{mix('/js/web/frame/jedate/jquery.jedate.js')}}"></script>
    <link rel="stylesheet" href="{{mix('/css/web/user/order_list.css')}}">
    <script src="{{mix('/js/web/user/order_list.js')}}"></script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">我的订单</div>
                <div class="my-subnav f-cb">
                    <ul>
                        <li @if(array_get($search_params, 'order_status') == 0) class="cur" @endif>
                            <a href="{{change_url_params(['order_status' => ''])}}" class="jm_hover">
                                所有订单
                            </a><i></i>
                        </li>
                        <li  @if(array_get($search_params, 'order_status') == 1) class="cur" @endif>
                            <a href="{{change_url_params(['order_status' => '1'])}}" class="jm_hover">
                                待付款
                            </a><i></i>
                        </li>
                        <li  @if(array_get($search_params, 'order_status') == 2) class="cur" @endif>
                            <a href="{{change_url_params(['order_status' => '2'])}}" class="jm_hover">
                                待发货
                            </a><i></i>
                        </li>
                        <li  @if(array_get($search_params, 'order_status') == 3) class="cur" @endif>
                            <a href="{{change_url_params(['order_status' => '3'])}}" class="jm_hover">
                                待收货
                            </a><i></i>
                        </li>
                        <li  @if(array_get($search_params, 'order_status') == 4) class="cur" @endif>
                            <a href="{{change_url_params(['order_status' => '4'])}}" class="jm_hover">
                                待评价
                            </a><i></i>
                        </li>
                        <li  @if(array_get($search_params, 'order_status') == 5) class="cur" @endif>
                            <a href="{{change_url_params(['order_status' => '5'])}}" class="jm_hover">
                                已取消
                            </a><i></i>
                        </li>
                    </ul>
                </div>
                <div class="search f-cb">
                    <form action="">
                        <input name='keyword' type="text" class="text fl" placeholder="商品名称/订单编号" value='{{array_get($search_params, "keyword")}}'>
                        <select class="select fl" title="" name='order_status'>
                            <option {{array_get($search_params, 'order_status') == 0 ? 'selected' : ''}} value="">所有订单类型</option>
                            <option  {{array_get($search_params, 'order_status') == 1 ? 'selected' : ''}} value="1">待付款</option>
                            <option  {{array_get($search_params, 'order_status') == 2 ? 'selected' : ''}} value="2">待发货</option>
                            <option  {{array_get($search_params, 'order_status') == 3 ? 'selected' : ''}} value="3">待收货</option>
                            <option  {{array_get($search_params, 'order_status') == 4 ? 'selected' : ''}} value="4">待评价</option>
                            <option  {{array_get($search_params, 'order_status') == 5 ? 'selected' : ''}} value="5">已取消</option>
                        </select>
                        <div class="time fl">
                            下单时间：
                            <input value='{{array_get($search_params, "created_at.start")}}' title="" name='created_at[start]' type="text" class="timetext workinput wicon" id="inpstart" readonly>
                            <span>至</span>
                            <input value='{{array_get($search_params,  "created_at.end")}}' title="" name='created_at[end]' type="text" class="timetext workinput wicon" id="inpend" readonly>
                        </div>
                        <input type="submit" class="submit fr" value="查询">
                    </form>
                </div>
                <div class="tit f-cb">
                    <div class="pr fl">订单商品</div>
                    <div class="pes fl">收货人 </div>
                    <div class="mon fl">金额</div>
                    <div class="sta fl">订单状态<i></i></div>
                    <div class="op fl">操作</div>
                </div>
                <div class="content">
                    @foreach($list as $order)
                    <div class="order">
                        <div class="boxtop f-cb">
                            <!-- <input type="checkbox" class="check fl"> -->
                            <div class="number fl">订单编号：

                                @if($order['order_type']!=6)
                                    <a href="/member/seller/orders/{{$order['id']}}">{{$order['order_code']}}</a>
                                @else
                                    <a href="javascript:void(0);">{{$order['order_code']}}</a>
                                @endif
                            </div>
                            <div class="business fl">商家：<a href="/shop/index/{{$order['shop_id']}}">{{array_get($order,'shop.sp_name')}}</a></div>
                            <div class="time flr">下单时间：{{ str_limit($order['created_at'],$limit = 10, $end = '') }}</div>
                        </div>
                        <div class="info ">
                            <table>
                                @if($order['order_type']==1 || $order['order_type']==6)
                                    @foreach($order['order_products'] as $k=>$orderPro)
                                        @if($k==0)
                                        <tr>
                                            <td width="80" height="100" class="imgbox">
                                                <img src="{{$orderPro['product_img_url']}}" width="80" height="80">
                                            </td>
                                            <td width="265" height="100" class="goods_name_box">
                                                <div class="goods_name">

                                                    @if($order['order_type']!=6)
                                                    <a target='_blank' href="/product/info/{{$orderPro['product_id']}}/{{$orderPro['sku_id']}}">{{$orderPro['product_name']}}</a>
                                                    @else
                                                        {{$orderPro['product_name']}}
                                                    @endif
                                                </div>
                                            </td>

                                            <td width="40" height="100" class="num" >×{{$orderPro['quantity']}} </td>
                                            <td width="99" height="100" class="name" rowspan="{{$product_count = count($order['order_products'])}}">{{$order['receiver']}}</td>
                                            <td width="150" height="100" class="price" rowspan="{{$product_count}}">
                                                <div class="cost">
                                                    <span class="tt"><span class="rmb">￥</span>{{$order['order_money']}}</span>
                                                    <span class="yf">(含运费：¥ {{$order['freight'] or '0.00'}})</span>
                                                </div>
                                            </td>
                                            <td width="150" height="100" class="statebox" rowspan="{{$product_count}}">
                                                <div>
                                                    <p>{{$order['order_status_name']}}</p>

                                                    @if($order['order_type']!=6)
                                                    <p><a href="/member/seller/orders/{{$order['id']}}" class="close jm_hover">查看详细</a></p>
                                                    @endif
                                                </div>
                                            </td>
                                            <td width="150" height="100" class="paybox" rowspan="{{$product_count}}">
                                                @if($order['order_status']==1)
                                                    <div class="btn_delivery modify_price" data-id='{{$order["id"]}}'>修改价格</div>
                                                    <div class="btn_delivery trade_close" data-id='{{$order["id"]}}'>关闭交易</div>
                                                @elseif($order['order_status']==2)
                                                    <div class="btn_delivery revise_price shipments_btn" data-id='{{$order["id"]}}'>发货</div>
                                                @elseif($order['order_status']==3)
                                                    <!-- <div class="btn_delivery" data-id='{{$order["order_code"]}}'>确认收货</div> -->
                                                    等待买家确认收货
                                                @elseif($order['order_status']==4)
                                                    交易完成
                                                    <div class="btn_delivery revise_evaluate" data-id='{{$order["id"]}}'>{{$order['seller_comment_status'] ? '查看评价' : '评价'}}</div>
                                                @elseif($order['order_status']==5)
                                                    已取消
                                                @endif

                                            </td>
                                        </tr>
                                        @else
                                        <tr>
                                            <td width="80" height="100" class="imgbox">
                                                <img src="{{$orderPro['product_img_url']}}" width="80" height="80">
                                            </td>
                                            <td width="235" height="100" class="goods_name_box">
                                                <div class="goods_name">
                                                    @if($order['order_type']==1)
                                                    <a target='_blank' href="/product/info/{{$orderPro['product_id']}}/{{$orderPro['sku_id']}}">{{$orderPro['product_name']}}</a>
                                                    @else
                                                        {{$orderPro['product_name']}}
                                                    @endif
                                                </div>
                                            </td>
                                            <td width="40" height="100" class="num" >× {{$orderPro['quantity']}} </td>
                                        </tr>
                                        @endif
                                    @endforeach
                                @elseif($order['order_type']==4)
                                    @foreach($order['items_products'] as $k=>$items_product)
                                    @if($k==0)
                                    <tr>
                                        <td width="80" height="80" class="imgbox">
                                            {{$items_product['product_name']}}
                                        </td>
                                        <td width="265" height="80" class="goods_name_box">
                                            <div class="goods_name">
                                                {{$items_product['model']}} {{$items_product['brand']}}
                                            </div>
                                        </td>

                                        <td width="40" height="80" class="num" >×{{$items_product['num']}} </td>
                                        <td width="99" height="80" class="name" rowspan="{{$product_count = count($order['items_products'])}}">{{$order['receiver']}}</td>
                                        <td width="150" height="80" class="price" rowspan="{{$product_count}}">
                                            <div class="cost">
                                                <span class="tt"><span class="rmb">￥</span>{{$order['order_money']}}</span>
                                                <span class="yf">({{in_array(1,$order['items_information']['quote_contain'])?'含票税':''}}    {{in_array(2,$order['items_information']['quote_contain'])?'含运费':''}}    {{in_array(3,$order['items_information']['quote_contain'])?'含安装':''}}    {{in_array(4,$order['items_information']['quote_contain'])?'含公报总价':''}})</span>
                                            </div>
                                        </td>
                                        <td width="150" height="80" class="statebox" rowspan="{{$product_count}}">
                                            <div>
                                                <p>{{$order['order_status_name']}}</p>

                                                @if($order['order_type']!=6)
                                                <p><a href="/member/seller/orders/{{$order['id']}}" class="close jm_hover">查看详细</a></p>
                                                @endif
                                            </div>
                                        </td>
                                        <td width="150" height="80" class="paybox" rowspan="{{$product_count}}">
                                            @if($order['order_status']==1)
                                                <div class="btn_delivery trade_close" data-id='{{$order["id"]}}'>关闭交易</div>
                                            @elseif($order['order_status']==2)
                                                <div class="btn_delivery revise_price shipments_btn" data-id='{{$order["id"]}}'>发货</div>
                                            @elseif($order['order_status']==3)
                                                <!-- <div class="btn_delivery" data-id='{{$order["order_code"]}}'>确认收货</div> -->
                                                等待买家确认收货
                                            @elseif($order['order_status']==4)
                                                交易完成
                                                <div class="btn_delivery revise_evaluate" data-id='{{$order["id"]}}'>{{$order['seller_comment_status'] ? '查看评价' : '评价'}}</div>
                                            @elseif($order['order_status']==5)
                                                已取消
                                            @endif
                                        </td>
                                    </tr>
                                    @else
                                    <tr>
                                        <td width="80" height="80" class="imgbox">
                                            {{$items_product['product_name']}}
                                        </td>
                                        <td width="235" height="80" class="goods_name_box">
                                            <div class="goods_name">
                                                {{$items_product['model']}} {{$items_product['brand']}}
                                            </div>
                                        </td>
                                        <td width="40" height="80" class="num" >× {{$items_product['num']}} </td>
                                    </tr>
                                    @endif
                                @endforeach
                                @endif
                            </table>
                        </div>
                    </div>
                    @endforeach
                </div>
                <div class="page">
                    @include('web.common.paginate')
                </div>
            </div>
        </div>
    </div>
</div>
<div class="bg_h"></div>

{{--发货--}}
@include('web.user.seller.common.shipments', ['express_company' => $express_company])

{{--改价--}}
<div class="revise_price_bombbox">
    <form action='' id="change-price-form">

    </form>
</div>

{{--评价--}}
<div class="revise_evaluate_bombbox" id='evaluate_bombbox'>
</div>

{{--关闭订单--}}
<div class="trade_close_bombbox">
</div>

@include('web.layout.footer')
<script type="text/javascript">
    var change_price_url = '/member/seller/orders/{id}/order_products/0/edit';
    var comment_url = '/member/seller/orders/{id}/user_comment/0';
    var order_update_edit = '/member/seller/orders/{id}/edit';

    var start = {
        format: 'YYYY-MM-DD hh:mm',
        minDate: '2014-06-16 23:59:59', //设定最小日期为当前日期
        //festival:true,
        maxDate: $.nowDate({DD:0}), //最大日期
        choosefun: function(elem,datas){
            end.minDate = datas; //开始日选好后，重置结束日的最小日期
            endDates();
        },
        okfun:function (elem,datas) {
            alert(datas)
        }
    };
    var end = {
        format: 'YYYY-MM-DD hh:mm',
        minDate: $.nowDate({DD:0}), //设定最小日期为当前日期
        //festival:true,
        maxDate: '2099-06-16 23:59:59', //最大日期
        choosefun: function(elem,datas){
            start.maxDate = datas; //将结束日的初始值设定为开始日的最大日期
        }
    };
    function endDates() {
        end.trigger = false;
        $("#inpend").jeDate(end);
    }
    $("#inpstart").jeDate(start);
    $("#inpend").jeDate(end);

    $(function(){
        //修改价格
        $('.modify_price').click(function(){
            var id = $(this).data('id');
            var url = change_price_url.replace('{id}', id);
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    $('.revise_price_bombbox form').html(data);
                    $('.revise_price_bombbox').show();
                    $('.bg_h').show();
                }
            });
        });

        //发货
        $('.shipments_btn').click(function(){
            var order_id = $(this).data('id');
            $('.express_confirm').data('id', order_id);
            $('.delivery_bombbox').show();
            $('.bg_h').show();
        });

        //评价
        $('.revise_evaluate').click(function(){
            var order_id = $(this).data('id');
            var url = comment_url.replace('{id}', order_id);
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    $('.revise_evaluate_bombbox').html(data);
                    $('.revise_evaluate_bombbox').show();
                    $('.bg_h').show();
                }
            });
        });

        //确定关闭交易
        $(".trade_close").on('click', function(event) {
            var order_id = $(this).data('id');
            var url = order_update_edit.replace('{id}', order_id);
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    $('.trade_close_bombbox').html(data);
                    $('.trade_close_bombbox').show();
                    $('.bg_h').show();
                }
            });


        });
    });

</script>
</body>
</html>